﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _01b_InitializingMatrix
{
    class Program
    {
        static void PrintMatrix(int[,] matrix)
        {
            for (int row = 0; row < matrix.GetLength(0); row++)
            {
                for (int column = 0; column < matrix.GetLength(1); column++)
                {
                    Console.Write(matrix[row, column] + "\t");
                }
                Console.WriteLine();
            }
        }
        static void Main(string[] args)
        {
            int sizeOfMatrix = int.Parse(Console.ReadLine());
            int[,] theGreatMatrix = new int[sizeOfMatrix, sizeOfMatrix];

            int currentPosition = 1;
            for (int column = 0; column < theGreatMatrix.GetLength(0) - 1; column += 2)
            {
                for (int row = 0; row < theGreatMatrix.GetLength(1); row++)
                {
                    (theGreatMatrix[row, column]) = currentPosition++;
                }
                for (int row = sizeOfMatrix - 1; row >= 0; row--)
                {
                    (theGreatMatrix[row, column + 1]) = currentPosition++;
                }
            }
            if (sizeOfMatrix % 2 == 1)
            {
                 for (int row = 0; row < theGreatMatrix.GetLength(1); row++)
                {
                    (theGreatMatrix[row, sizeOfMatrix - 1]) = currentPosition++;
                }
            }
            PrintMatrix(theGreatMatrix);
        }
    }
}
